package com.order.controller;


import com.common.common.BaseResponse;
import com.common.common.ResultUtils;
import com.common.controller.AbstractTypedController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import com.order.entities.OrderDetailet;
import com.order.service.OrderDetailServiceImpl;
import com.order.vo.OrderDetailVo;
import com.order.vo.OrderPayInfo;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * @Author fu
 * @Date 2023 01 04 11 44
 **/
@Component
@RestController
@RequestMapping("orderdetails")
@Slf4j
@CrossOrigin
@Tag(name = "订单详情")
public class OrderDetailController extends AbstractTypedController<OrderDetailet, Integer> {
    @Resource
    private OrderDetailServiceImpl orderDetailService;
    OrderDetailController(OrderDetailServiceImpl orderDetailService ) {
        this.svcContext = orderDetailService;
        this.orderDetailService =orderDetailService ;
    }

    @PostMapping("/insert")
    @Operation(summary = "创建订单详细")
    public BaseResponse<Boolean> addOrderList(@RequestBody List<OrderDetailVo> orderDetailVos){
        System.out.println(orderDetailVos);
        return ResultUtils.success(orderDetailService.insertOrder(orderDetailVos));
    }

    @GetMapping("/getorder/{orderId}")
    @Operation(summary = "获取订单")
    public BaseResponse<OrderPayInfo> getorder(@PathVariable Integer  orderId){
        return ResultUtils.success(orderDetailService.getByOrderId(orderId));
    }



//    @PostMapping("/orderList")
//    @Operation(summary = "获取订单")
//    public BaseResponse<List> orderList( @RequestParam String  userId){
//        return ResultUtils.success(orderDetailService.getByUserId(userId));
//    }
}
